package com.eshop.servlet;

import java.io.IOException;
import java.io.PrintWriter;
import java.util.ArrayList;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import com.eshop.bean.GoodsBean;
import com.eshop.dao.ProductDetailsDao;

public class ProductDetailsServlet extends HttpServlet {


	public ProductDetailsServlet() {
		super();
	}

	
	public void destroy() {
		super.destroy();
	}

	
	public void doGet(HttpServletRequest request, HttpServletResponse response)
			throws ServletException, IOException {
		doPost(request, response);
	
	}

	
	public void doPost(HttpServletRequest request, HttpServletResponse response)
			throws ServletException, IOException {
		Integer goods_id = Integer.valueOf(request.getParameter("id"));
		if(goods_id == 0)
		{
			goods_id = 1;
		}
		
		ProductDetailsDao productDetailsDao = new ProductDetailsDao();
		ArrayList<GoodsBean> productDetails = productDetailsDao.productDetails(goods_id);
		
		request.setAttribute("information", productDetails);
		
		request.getRequestDispatcher("/PAGE/single-product.jsp").forward(request, response);
	}


	public void init() throws ServletException {
	
	}

}
